package com.bing.habit.controller.admin;

import com.bing.habit.entity.HabitIcon;
import com.bing.habit.model.result.Result;
import com.bing.habit.model.result.ResultFactory;
import com.bing.habit.service.HabitIconService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 习惯图标管理
 */
@RestController
@RequestMapping("/admin/habit_icon")
public class HabitIconController {

    @Autowired
    HabitIconService habitIconService;

    /**
     * 新增/更新 图标分类
     */
    @PostMapping
    public Result addOrUpdate(@RequestBody HabitIcon habitIcon){
        habitIconService.addOrUpdate(habitIcon);
        return ResultFactory.buildSuccessResult("添加图标成功");
    }

    /**
     * 删除
     * @param habitIconId
     * @return
     */
    @DeleteMapping("/{habitIconId}")
    public Result delete(@PathVariable("habitIconId") int habitIconId){
        habitIconService.delete(habitIconId);
        return ResultFactory.buildSuccessResult("删除图标成功");
    }

    /**
     * 根据cid获取
     * @return
     */
    @GetMapping("/{HabitIconId}")
    public Result get(){
        return null;
    }

    /**
     * 列出习惯图标
     * @param page
     * @param size
     * @return
     */
    @GetMapping("/list")
    public Result list(@RequestParam("page") int page,
                       @RequestParam("size") int size){
        return null;
    }
}
